package biz

import (
	"github.com/gin-gonic/gin"
)

type User struct {
	Id	int64
	Name string
	Addr string
}

type UserRepo interface {
	CreateUser(ctx *gin.Context, u User) (User, error)
	GetUser(ctx *gin.Context, uID int64) (User, error)
	UpdateUser(ctx *gin.Context, u User) (User, error)
	DeleteUser(ctx *gin.Context, uID int64) (User, error)
}

type UserUseCase struct {
	repo UserRepo
}

func ProviderUserUseCase(repo UserRepo) *UserUseCase {
	return &UserUseCase{repo: repo}
}

func (uc *UserUseCase)Create(ctx *gin.Context, u User) (User, error) {
	return uc.repo.CreateUser(ctx, u)
}

func (uc *UserUseCase)Get(ctx *gin.Context, uID int64) (User, error) {
	return  uc.repo.GetUser(ctx, uID)
}

func (uc *UserUseCase)Update(ctx *gin.Context, u User) (User, error) {
	return uc.repo.UpdateUser(ctx, u)
}

func (uc *UserUseCase)Delete(ctx *gin.Context, uID int64) (User, error) {
	return uc.repo.DeleteUser(ctx, uID)
}
